/*
 * @Author: 
 * @Date: 2024-08-26 17:06:44
 * @LastEditor: zhuxiaoyi
 * @LastEditTime: 2024-09-20 17:25:43
 * @Description: 
 */
import {
  Body,
  Controller,
  Del,
  File,
  Get,
  Inject,
  Param,
  Post,
  Put,
  Query,
} from '@midwayjs/core';
import { ApiBody, BodyContentType, ApiResponse, Type } from '@midwayjs/swagger';
import { Validate } from '@midwayjs/validate';
import { CreateTaskDto, uploadDto } from '../dto/SimulationTaskDto';
import { SimulationTaskService } from '../service/simulationTask.service';
import { Context } from '@midwayjs/koa';



@Controller('/floodApi')
export class APIController {
  @Inject()
  simulationTaskService: SimulationTaskService;

  @Inject()
  ctx: Context;

  @Post('/SimulationTask/beijig', { summary: '内涝模拟结果任务创建(北京)' })
  @Validate()
  async createSimulationTask1(@Body() params: CreateTaskDto) {
    return await this.simulationTaskService.createSimulationTask(params);
  }

  @Post('/SimulationTask/quanguo', { summary: '内涝模拟结果任务创建(全国)' })
  @Validate()
  async createSimulationTask2(@Body() params: CreateTaskDto) {
    return await this.simulationTaskService.createQuanguoSimulationTask(params);
  }

  @Post('/SimulationTask/upload', { summary: '降雨数据文件接收(北京预警/全国预警)' })
  @ApiBody({
    description: '降雨数据文件接收(北京预警)',
    contentType: BodyContentType.Multipart,
  })
  async uploadFile( @Query() params: uploadDto,@File() file: any) {
    return await this.simulationTaskService.uploadFile(params, file);
  }


  /* @Post('/WarningTask/quanguo', { summary: '降雨数据文件接收(全国预警)' })
  @ApiBody({
    description: '降雨数据文件接收(全国预警)',
    contentType: BodyContentType.Multipart,
  })
  async uploadFile2( @Query() params: uploadDto,@File() file: any) {
    return await this.simulationTaskService.uploadFile2(params, file);
  } */


  @Post('/downloadRainfallData', { summary: '降雨数据下载' })
  async downloadRainfallData( ) {
    return await this.simulationTaskService.downloadRainfallData();
  }
  
  @Post('/downloadHistoryData', { summary: '历史数据下载' })
  async downloadHistoryData( ) {
    return await this.simulationTaskService.downloadHistoryData(1,2,1);
  }
  
  @Post('/pushPreviewData', { summary: '北京预警数据推送' })
  async pushPreviewData( ) {
    return await this.simulationTaskService.pushPreviewData();
  }
  @Post('/pushPreviewData2', { summary: '北京预警数据推送2' })
  async pushPreviewData2( ) {
    return await this.simulationTaskService.pushPreviewData2();
  }
}
